<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>注册</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="lib/layui/css/layui.css" media="all"/>
</head>
<body style="background-color: whitesmoke">

<div style="padding: 30px; width: 600px;  margin: auto; margin-top: 100px">


    <h1 style="text-align: center">注册管理员</h1>
    <form class="layui-form" action="" lay-filter="example" id="formDom" style="padding: 30px">


        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="mobile" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" name="email" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="password1" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <button class="layui-btn " lay-submit="" lay-filter="register" style="margin-left: 180px">注册</button>
            </div>
        </div>

    </form>

    <div class="layui-form-item">
        <div style="margin-top: 30px; text-align: right; padding-right: 40px; ">
            <a href="login.html">已有账号，去登录</a>
        </div>
    </div>
</div>

<script type="text/javascript" src="lib/layui/layui.js"></script>
<script type="text/javascript" src="common/js/config.js"></script>
<script>
    layui.config({
        base: $config.resUrl + '/web/common/js/'//定义基目录
    }).extend({
        ajaxExtention: 'ajaxExtention', //加载自定义扩展
        $tool: 'tool',
        $api: 'api'
    }).use(['form', 'layer', 'ajaxExtention', '$tool', '$api'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : parent.layer,
            $ = layui.jquery,
            $tool = layui.$tool,
            $api = layui.$api;


        //登录按钮事件
        form.on("submit(register)", function (data) {
            var form_data = form.val('example');
            if (form_data.password == form_data.password1) {
                var url = $tool.getContext() + '/sysAdmin/register';
                $.ajax({
                    type: "post",
                    url: url,
                    data: form_data,
                    // dataType: "json",
                    success: function (res) {
                        if (res.code == 200) {
                            window.location.href = $tool.getResUrl() + "/web/login.html";
                        }
                    }
                });
            } else {
                layer.msg('两次密码不一样', {time: 500})
            }
            return false;
        });

    });

</script>
</body>

</html>